<include file="Public/common" />
<block name="content">
    <style>
        th,td{text-align: center;}
    </style>
    <div class="page-header"><h1><i class="fa fa-home"></i> 首页 &gt; 后台管理 &gt; 员工列表</h1></div>




    <div class="col-xs-12">

        <div class="tab-content">
            <div class="row" >
                <form action="" class="form-inline " method="get" style="margin-left:10px;" >
                    <div class="form-group">
                        <label for="userName">员工名称</label>
                        <input type="text" class="" name="userName" id="userName" placeholder="员工名称" value="{$post.userName}">
                    </div>
                    <button type="submit" class="btn btn-primary">查询</button>
                </form>
            </div>
        </div>

        <div class="tabbable">
            <ul class="nav nav-tabs padding-12 tab-color-blue background-blue" id="myTab">
                <li class="active"><a href="{:U('Rule/admin_user_list')}">员工列表</a></li>
                <li><a href="{:U('Rule/add_admin')}">添加员工</a></li>
            </ul>
            <div class="tab-content">
                <table class="table table-striped table-bordered table-hover table-condensed">
                    <tr>
                        <th>id</th>
                        <th width="10%">登录帐号</th>
                        <th>真实姓名</th>
                        <th>所属部门</th>
                        <th>联系手机</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                    <foreach name="data" item="v">
                        <tr>
                            <td>{$v['supplier_id']}</td>
                            <td>{$v['supplier_account']}</td>
                            <td>{$v['username']}</td>
                            <td>{$v['title']}</td>
                            <td>{$v['supplier_phone']}</td>
                            <td><if condition="$v['supplier_status']">正常<else/>锁定</if></td>
                            <td>
                                <a href="{:U('Rule/edit_admin',array('id'=>$v['id']))}" class="btn btn-xs btn-primary ">编辑</a>
                                <if condition="$v['pid'] gt 0">
                                    <if condition="$v['supplier_status']">
                                        <a href="javascript:changeUserStatus('{$v['id']}',0)" class="btn btn-xs btn-warning">禁用</a>
                                        <else/>
                                        <a href="javascript:changeUserStatus('{$v['id']}',1)" class="btn btn-xs btn-primary">启用</a>
                                    </if>
                                </if>
                            </td>
                        </tr>
                    </foreach>
                </table>
            </div>
        </div>
    </div>
    <script>
        function changeUserStatus(uid,status) {
            var operation='启用';
            if(status==0){
                operation='禁用';
            }
            //询问框
            layer.confirm('确定'+operation+'此用户吗?', {
                btn: ['确定','取消'] //按钮
            }, function(){
                $.ajax({
                    url:'{:U("Rule/changeUserStatus")}',
                    dataType:"json",
                    type:'POST',
                    cache:false,
                    data:{uid:uid,status:status},
                    success: function(data) {
                        layer.msg(data.msg);
                        if (data.status==1) {
                            setTimeout(function () {
                                location.reload();
                            },1500);
                        }
                    }
                });
            });


        }
    </script>
</block>
